$.extend(planner, {
    server: 
    {
        post_mech: function(params, done, fail, json)
        {
            console.log("planner.server.post_mech()");
            if ( !params ) params = {};
            if ( !done ) done = function(data) {};
            if ( !fail ) fail = function(data) {};
                  
            var payload = { 
                d:          planner.mech.dropid, 
                p:          planner.mech.player, 
                sp:         planner.mech.speed,
                m:          planner.mech.mechtype,
                w:          planner.mech.weapons.join(","),
                e:          [planner.mech.modules.join(","), planner.mech.equipment.join(",")].join(","),
            };
            
            var ajax = { 
                url: "/",
                type: "POST",
                data: payload
            };
            
            for (key in params)
                payload[key] = params[key];
            
            if ( json )
                ajax['dataType'] = 'json';
                
            console.log("planner.server.post_mech: posting");

            $.ajax( ajax ).done( function(data){
 
                console.log("planner.server.post_mech: done");
                planner.roster.lastHtml = data;
                if (done)
                {
                    console.log("planner.server.post_mech: calling callback");
                    done(data);
                }

               // console.log("lastHtml" + planner.roster.lastHtml)
            }).fail( function() {
                console.log("planner.server.post_mech: calling failback");
                    
                planner.roster.lastHtml = "";
                if (fail) fail();
            });
        },
    }    
});